<template>
	<view class="flex flex-col h-full">
		<scroll-view scroll-y="true" class="flex-1">
			<view class="" v-if="step == 1">
				<view class="mb-20">
					<text class="text-sm font-bold">您的具体问题是:</text>
					<uni-easyinput class="mt-20" type="textarea" autoHeight v-model="formData.problem"
						placeholder="我最近总是觉得做什么都没干劲总觉得自己很无能，想知道自己是不是抑郁了."></uni-easyinput>
				</view>
				<view class="mb-20">
					<text class="text-sm font-bold mb-20">您是否有不适感(可多选):</text>
					<uni-data-checkbox multiple v-model="addparme" :localdata="addparmeList"></uni-data-checkbox>
				</view>
				<view class="mb-20">
					<text class="text-sm font-bold">补充说明:</text>
					<uni-easyinput class="mt-20" v-model="formData.replenishment"
						placeholder="总是听到一些奇怪的声音。"></uni-easyinput>
				</view>
				<view class="mb-20">
					<text class="text-sm font-bold">例如:</text>
					<view class="bg-[#F0F3F4] p-20 text-[#666666] mt-20">总是听到一些奇怪的声音。</view>
				</view>
			</view>
			<view class="" v-if="step == 2">
				<sendSettingVue :isCard="isCard"></sendSettingVue>
			</view>
			<view class="" v-if="step == 3">
				<payCompVue @send="handleSend"></payCompVue>
			</view>
		</scroll-view>
		<view class="pt-30" v-if="step!==3">
			<button type="primary" class="rounded-full" @click="onSave">确定</button>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		inject,
		watch,
		computed
	} from 'vue';
	import radioCompVue from './radioComp.vue';
	import sendSettingVue from './sendSetting.vue';
	import payCompVue from './payComp.vue';
	const pretList = inject('pretList')
	const systemSetting = inject('systemSetting')
	const postFrom = inject('postFrom')
	const step = inject('step')
	
	const emit = defineEmits(['update', 'send'])
	
	const payPrice = computed(() => {
		if (postFrom.value.sec == 1) {
			return postFrom.value.sinpay * postFrom.value.pret * 1 + 12
		}else {
			return postFrom.value.sinpay * postFrom.value.pret * 1
		}
	})
	
	const addparme = ref([]) // 不适感
	const formData = ref({
		problem: '',
		replenishment: '',
	}) 
	const replenishment = ref("") // 补充
	const isCard = ref(false) // 是否为卡牌区
	
	const addparmeList = [
		{
			text: "难以入睡",
			value: "难以入睡"
		}, {
			text: "冲动易怒",
			value: "冲动易怒"
		}, {
			text: "胡思乱想",
			value: "胡思乱想"
		}, {
			text: "伤害自己",
			value: "伤害自己"
		}, {
			text: "食欲不振",
			value: "食欲不振"
		}, {
			text: "周身酸痛",
			value: "周身酸痛"
		}, {
			text: "无法沟通",
			value: "无法沟通"
		}, {
			text: "恐惧社交",
			value: "恐惧社交"
		}, {
			text: "全身无力",
			value: "全身无力"
		}, {
			text: "迷惘无助",
			value: "迷惘无助"
		}, {
			text: "逐渐消瘦",
			value: "逐渐消瘦"
		}, {
			text: "暴饮暴食",
			value: "暴饮暴食"
		},
	]
	
	const handleSend = () => {
		emit('send')
	}
	
	const onSave = () => {
		console.log(formData.value.problem)
		if (step.value == 1) {
			if (formData.value.problem == '') {
				uni.showToast({
					icon: "none",
					title: "请填写您的问题！"
				})
				return
			}
		}else if(step.value == 2) {
			if (postFrom.value.sinpay == '') {
				uni.showToast({
					icon: "none",
					title: "请选择打赏金额！"
				})
				return
			}
			postFrom.value.pret = 0
			// if (postFrom.value.pret == 0) {
			// 	uni.showToast({
			// 		icon: "none",
			// 		title: "请选择解读人数！"
			// 	})
			// 	return
			// }
		}
		const obj = {
			addparme: addparme.value.join(','),
			describe: formData.value.problem,
			replenishment: formData.value.replenishment,
		}
		emit("update", obj)
	}
</script>

<style lang="scss" scoped>
	:deep(.uni-easyinput__content) {
		background-color: #F0F3F4 !important;
		border-radius: 10rpx !important;
	}
</style>